#!/usr/bin/env bash

set -o nounset
set -o errexit
set -o pipefail

STARTUP_DIR="$( cd "$( dirname "$0" )" && pwd )"

SFILE=${STARTUP_DIR}/grafana-prom-admin-password.txt
if [ ! -f "${SFILE}" ]; then
    openssl rand -base64 12 > ${SFILE} && echo "created: ${SFILE}"
fi

GRAFANA_PROM_ADMIN_PASSWORD="$(cat ${SFILE})"
kubectl delete --ignore-not-found=true secret grafana-prom-secret
kubectl create secret generic grafana-prom-secret --from-literal=grafana-prom-admin-password="${GRAFANA_PROM_ADMIN_PASSWORD}"

